from django.http import HttpResponse


# 中间件函数
class BlockedIPSMiddleware(object):
	DENY_IPS = ['192.168.0.188']

	def __init__(self):
		print("我被调用了")

	@staticmethod
	def process_view(request, view_func, *view_args, **view_kargs):
		"""url匹配之后,視圖函数调用之前调用"""
		user_ip = request.META['REMOTE_ADDR']
		if user_ip in BlockedIPSMiddleware.DENY_IPS:
			return HttpResponse("<h1>Forbidden</h1>")
